package tq.com.tqcom.vh;

import android.content.Context;
import android.support.constraint.ConstraintLayout;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import tq.com.tqcom.R;

public class ComSpacerViewHolder extends RecyclerView.ViewHolder {
    private int height = 0;

    public static ComSpacerViewHolder instance(int h, ViewGroup parent, Context pContext){
        View lView = LayoutInflater.from(pContext).inflate(R.layout.vh_space_layout, parent, false);
        ComSpacerViewHolder lViewHolder = new ComSpacerViewHolder(lView, h);
        return lViewHolder;
    }
    public ComSpacerViewHolder(View pView, int pHeight){
        super(pView);

        TextView s = pView.findViewById(R.id.spacer);
        ConstraintLayout.LayoutParams lParams = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                (int)pView.getContext().getResources().getDisplayMetrics().density * pHeight);
        s.setLayoutParams(lParams);
    }

    public void bindHeight(int pHeight){
        TextView s = itemView.findViewById(R.id.spacer);
        ConstraintLayout.LayoutParams lParams = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                (int)itemView.getContext().getResources().getDisplayMetrics().density * pHeight);
        s.setLayoutParams(lParams);
    }
}
